/**
 * 版权所有:版权所有(C) 2020，卓信科技
 * 系统名称:FOL-财务在线
 * 文件名称:ExceptionUtil.java
 * 模块名称:TODO(这里请补充模块名称)
 * 创建日期:2020年5月19日
 * 作        者:Baisong
 * 内容摘要:TODO(这里请补充详细的描述信息)
 */
package com.zx.platform.syscontext.util;

/**
 * 类  名  称:ExceptionUtil
 * 
 * 内容摘要:TODO(发送消息)
 * 
 * 作        者:Baisong
 */
public class ExceptionUtil 
{
	/**
	 * 以运行时异常方式抛出异常<br />
	 * Throws checked exceptions in un-checked manner.
	 * @see #throwException(Throwable) 
	 */
	public static void throwException(Throwable throwable) 
	{
		// 判断
		if (throwable instanceof RuntimeException) 
		{
			throw (RuntimeException) throwable;
		}
		// can't handle these types
		if ((throwable instanceof IllegalAccessException) || (throwable instanceof InstantiationException)) 
		{
			throw new IllegalArgumentException(throwable);
		}

		try 
		{
			synchronized (ThrowableThrower.class) 
			{
				ThrowableThrower.throwable = throwable;
				ThrowableThrower.class.newInstance();
			}
		} 
		catch (InstantiationException iex) 
		{
			throw new RuntimeException(iex);
		} 
		catch (IllegalAccessException iex) 
		{
			throw new RuntimeException(iex);
		} 
		finally 
		{
			ThrowableThrower.throwable = null;
		}
	}
	
	/**
	 * ThrowableThrower
	 */
	private static class ThrowableThrower 
	{
		private static Throwable throwable;
		ThrowableThrower() throws Throwable 
		{
			throw throwable;
		}
	}
}
